<script src="{{ .Site.BaseURL }}/scripts/changevalue.js"></script>
<section class="post-comments">
	
  {{ $postId := .File.BaseFileName }}

  <h2 id="comments" >Comments</h2>

  {{ $.Scratch.Set "hasComments" 0 }}

  {{ range $comments := index $.Site.Data.comments $postId }}
		{{ $.Scratch.Add "hasComments" 1 }}
			{{ if not .reply_to }}
				<div class="post-comment" >
				  <div class="post-comment-header">
					  <p class="post-comment-info" id="{{ ._id }}" style="border-bottom:1px;border-bottom-color:black"><strong>{{ .name }}</strong> on {{ dateFormat "Monday, Jan 2, 2006" .date }}:</p>
				  </div>
				  {{ .body | markdownify }}
				  <div class="comment_reply">
					  <br>
	<a class="btn-info" href="#comment-form" onclick="changeValue('fields[reply_to]', '{{ ._id }}')"> Reply to {{ .name }}</a>
				</div>
				</div>
				{{ partial "comment-replies" (dict "entryId_parent" $postId "SiteDataComments_parent" $.Site.Data.comments "parentId" ._id "parentName" .name "context" .) }}
			{{ end }}
	{{ end }}

  {{ if eq ($.Scratch.Get "hasComments") 0 }}
		<p>Nothing yet. Be the first!</p>
  {{ end }}
</section>
